#include "Logger.h"
#include "Timestamp.h"

#include <iostream>

Logger Logger::logger;

// 获取单例对象接口
Logger &Logger::getInstance()
{
    return logger;
}

// 设置日志等级
void Logger::setLogLevel(int logLevel)
{
    logLevel_ = logLevel;
}

// 写日志, [日志等级]时间 : msg
void Logger::log(std::string msg)
{
    switch (logLevel_)
    {
    case INFO:
        std::cout << "[INFO ]";
        break;
    case ERROR:
        std::cout << "[REEOR]";
        break;
    case FATAL:
        std::cout << "[FATAL]";
        break;
    case DEBUG:
        std::cout << "[DEBUG]";
        break;
    default:
        break;
    }

    std::cout << Timestamp::now().toString() << " : " << msg << std::endl;
}